package com.ds.duizhang20221212.dto;

import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.Date;

public class Test {
    @SneakyThrows
    public static void main(String[] args) {
        System.out.println(new Date().getTime());
        System.out.println(new Date().toInstant());
        LocalTime time = LocalTime.of(12,10,3,777);


        SimpleDateFormat simpleDateFormatSource = new SimpleDateFormat("yyyy/M/dd");
        SimpleDateFormat simpleDateFormatTarget = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormatSource.parse("2022/4/14 14:59");
        System.out.println(simpleDateFormatTarget.format(parse));

        System.out.println(parseDouble("1,900.00"));

        BigDecimal b1 = new BigDecimal(-82289.6);
        BigDecimal b2 = new BigDecimal(-36765.28);
        System.out.println(b1.subtract(b2).abs().compareTo(BigDecimal.TEN)<0);
    }

    private static double parseDouble(String s) {
        if(StringUtils.contains(s,",")){
            s=StringUtils.replace(s,",","");
        }
        return Double.parseDouble(s);
    }
}
